package com.zh.test.ProxyAndAspect.filterAspect;

import com.zh.test.bean.OutJson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * @Author zh
 * @Description  测试过滤器AOP
 * @Date 2020/9/4
 * @Param
 * @return
 **/
@RestController
@RequestMapping("/filter")
@Slf4j
public class filterAspectController {
    @Autowired
    fileAspectServcie fileAspectServcie;

    //添加过滤事件,注意有事件顺序要求
    @CheckFilter()
    @RequestMapping("/test")
    public void test (){
        log.info("进入被植入方法测试方法");
    }
    @CheckFilter()
    @PostMapping("/test1")
    public OutJson test1(@RequestBody HashMap<String,String> m){
        m.forEach((k,v)->{
            System.out.println(k+":"+v);
        });
        return  new OutJson().setObject("success").setMessage("200");
    }

    @PostMapping("/test2")
    public OutJson test2(@RequestBody HashMap<String,String> m){
        fileAspectServcie.test(m);
        return  new OutJson().setObject("success").setMessage("200");
    }
}
